﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Skynet.WebAdministracion.Views.DesignAlternative;
using Microsoft.Practices.Unity;

namespace Skynet.WebSite.Administration
{
    public partial class DesignAlternativeView : Infrastructure.Web.Views.Page, IDesignAlternativeView
    {
        private DesignAlternativePresenter _Presenter;

        [Dependency]
        public DesignAlternativePresenter Presenter
        {
            get { return _Presenter; }
            set
            {
                _Presenter = value;
                this._Presenter.View = this;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)            
                this.Presenter.OnViewInitialized();            
            else
                this.Presenter.OnViewLoaded();
        }

        public string QuestionTitle
        {
            set { this.lblQuestionTitle.Text = value; }
        }

        public double Score
        {
            get
            {
                return double.Parse(this.txtScore.Text);
            }
            set
            {
                this.txtScore.Text = value.ToString();
            }
        }

        protected void lbQuestions_Click(object sender, EventArgs e)
        {
            this.Presenter.BackQuestions();
        }


        public Control AlternativeControl
        {
            get
            {
                Control result = null;
                foreach (var item in pnAlternatives.Controls)
                {
                    if (!(item is Literal))
                        result =  item as Control;                    

                }
                return result;
            }
            set
            {
                this.pnAlternatives.Controls.Add(value);
            }
        }

        protected void lbNewAlternative_Click(object sender, EventArgs e)
        {
            this.Presenter.NewAlternative();
        }
    }
}